<div ng-include="sys_html('common/_header')"></div>
<div class="fui-page page-merch-register">
    <div class="fui-content">
        <img style='width:100%;position: relative' ng-src="{{tomedia(pagedata.pluginset.addtopbg) || '../addons/jy_h5live/resource/img/hdp01.jpg'}}" />
			<div class="weui_cells weui_cells_form" style="margin-top:0">			
				<div class="weui_cell">
					<div class="weui_cell_hd"><label class="weui_label">直播间名字</label></div>
					<div class="weui_cell_bd weui_cell_primary">
						<input class="weui_input" ng-model="pagedata.item.title" type="text" name="title" placeholder="输入直播间名字"/>
					</div>
				</div>
				<div class="weui_cell">
					<div class="weui_cell_hd"><label class="weui_label">封面图</label></div>
					<div class="weui_cell_bd weui_cell_primary">
						<ul class="weui_uploader_files" ng-if="pagedata.item.image">
							  <li class="weui_uploader_file" style="background-image:url({{tomedia(pagedata.item.image)}})"></li>
						</ul>
						<div class="weui_uploader_input_wrp">
							 <span class="weui_uploader_input" ng-model="pagedata.item.image" ng-click="image(pagedata.item,'image')" accept="image/jpg,image/jpeg,image/png,image/gif" multiple=""></span>
						</div>
					</div>
				</div>
				<div class="weui_cell">
					<div class="weui_cell_hd"><label class="weui_label">直播时间</label></div>
					<div class="weui_cell_bd weui_cell_primary">
						<input class="weui_input" type="date" ng-model="pagedata.item.livetime" placeholder=""/>
					</div>
				</div>
				<div class="weui_cell">
					<div class="weui_cell_hd"><label class="weui_label">分类</label></div>
					<div class="weui_cell_bd weui_cell_primary">
						<select class="weui_select" style="padding:0.3rem" name="cateid2" ng-model="pagedata.item.group_id">
							<option ng-repeat="item in pagedata.groups" value="{{item.id}}">{{item.title}}</option>
						</select>
					</div>
				</div>
				<div class="weui_cell">
					<div class="weui_cell_hd"><label class="weui_label">直播间类型</label></div>
					<div class="weui_cell_bd weui_cell_primary">
						<div class="fui-cell-label" ng-repeat="(key,value) in pagedata.types"  style="margin-right:0.8rem;float:left;margin-bottom:0.2rem">
							<input type="radio" ng-click="pagedata.item.type=key" ng-checked="pagedata.item.type==key" class="fui fui-radio fui-radio-danger verify-radio" value="{{key}}"> {{value}}
						</div>
					</div>
				</div>
				<div class="weui_cell">
					<div class="weui_cell_hd"><label class="weui_label">直播平台</label></div>
					<div class="weui_cell_bd weui_cell_primary">
						<div ng-if="pagedata.item.type==0" class="fui-cell-label" ng-repeat="(key,value) in pagedata.type0"  style="margin-right:0.8rem;float:left;margin-bottom:0.2rem">
							<input type="radio" ng-click="pagedata.item.livept=key" ng-checked="pagedata.item.livept==key" class="fui fui-radio fui-radio-danger verify-radio" value="{{key}}"> {{value}}
						</div>
						<div ng-if="pagedata.item.type==1" class="fui-cell-label" ng-repeat="(key,value) in pagedata.type1"  style="margin-right:0.8rem;float:left;margin-bottom:0.2rem">
							<input type="radio" ng-click="pagedata.item.livept=key" ng-checked="pagedata.item.livept==key" class="fui fui-radio fui-radio-danger verify-radio" value="{{key}}"> {{value}}
						</div>
						<div ng-if="pagedata.item.type==2" class="fui-cell-label" ng-repeat="(key,value) in pagedata.type2"  style="margin-right:0.8rem;float:left;margin-bottom:0.2rem">
							<input type="radio" ng-click="pagedata.item.livept=key" ng-checked="pagedata.item.livept==key" class="fui fui-radio fui-radio-danger verify-radio" value="{{key}}"> {{value}}
						</div>
					</div>
				</div>
				<div ng-if="pagedata.item.type==2" class="weui_cell">
					<div class="weui_cell_hd"><label class="weui_label">直播间二维码</label></div>
					<div class="weui_cell_bd weui_cell_primary">
						<ul class="weui_uploader_files" ng-if="pagedata.item.image">
							  <li class="weui_uploader_file" style="background-image:url({{tomedia(pagedata.item.roomewm)}})"></li>
						</ul>
						<div class="weui_uploader_input_wrp">
							 <span class="weui_uploader_input" ng-model="pagedata.item.roomewm" ng-click="image(pagedata.item,'roomewm')" accept="image/jpg,image/jpeg,image/png,image/gif" multiple=""></span>
						</div>
					</div>
				</div>
				<div ng-if="pagedata.item.type<=1 && (pagedata.item.livept=='inke' || pagedata.item.livept=='douyu')" class="weui_cell">
					<div class="weui_cell_hd"><label class="weui_label">直播抓取</label></div>
					<div class="weui_cell_bd weui_cell_primary">
					<span class="label label-success" ng-click="pagedata.showgetvideourl=true">点击抓取</span>
					</div>
				</div>
				<div class="weui_cell">
					<div class="weui_cell_hd"><label class="weui_label">HLS直播地址</label></div>
					<div class="weui_cell_bd weui_cell_primary">
					<textarea class="weui_textarea" style="background:#f2f2f2;padding:0.2rem" rows="2" ng-model="pagedata.item.video" placeholder="输入HLS直播地址"></textarea>
					<div class="help gray" style="font-size:0.6rem">HLS直播地址为后缀名为http://域名/xxxxx.m3u8或.flv结尾的链接</div>
					</div>
				</div>
				<div class="weui_cell weui_cell_switch">
							<div class="weui_cell_hd weui_cell_primary">状态</div>
							<div class="weui_cell_ft">
								<input class="weui_switch" type="checkbox" ng-checked="pagedata.item.status" ng-model="pagedata.item.status">
							</div>
				</div>
			</div>
			<div ng-if="pagedata.pluginset.applytitle!=null && pagedata.pluginset.applycontent!=null" class="fui-cell-group">
				<div class="fui-cell small ">
					<div class="fui-cell-info">
						<label class="checkbox-inline">
                            <input type="checkbox" class="fui-checkbox-primary" id="agree" ng-checked="pagedata.item.check==1"/> 我已经阅读并了解了<a ng-click="pagedata.show=1" id="btn-apply" style="color:#337ab7;">【{{pagedata.pluginset.applytitle}}】</a>。
                        </label>
					</div>
				</div>
			</div>
			<div class="modal-bg pop-apply-hidden" ng-if="pagedata.show==1">
				<div class="modal-content" style="top:10%;width:90%;left:5%">
						<div class="closebtn" ng-click="pagedata.show==0" style="opacity:1;"><i class="icon icon-cuowu"></i></div>
						<div class="news-body">
							<div class="title">{{pagedata.pluginset.applytitle}} / <small>Read &nbsp;Ggree</small></div>
							<div class="text" ng-bind-html="trust(pagedata.pluginset.applycontent)"></div>
						</div>
						<div class="modal-footer">
								<div ng-click="pagedata.show=false" class="mod-check" style="width: 100%; margin: 0;">我已阅读</div>
						</div>
				</div>
			 </div>
			 <div class='btn block btn-submit' style="background:linear-gradient(to right,rgba(124,47,239,1),rgba(165,88,226,1));color:#fff;margin:0.5rem 1rem;border-radius:1.8rem;line-height:1.8rem" ng-click="post(pagedata.item,'post')">提交</div>
   </div> 
</div>
<!--获取地址弹窗 -->
<div ng-if="pagedata.showgetvideourl" class="popup">
            <div class="popup-body">
			<div class="popup-center rp-background-lightgray" style="border-radius:0.5rem;">
				<i class="closed icon icon-cuowu" ng-click="pagedata.showgetvideourl=false"></i>
				 <div class="weui_cells" style="height:13rem;background-color:white;border-radius:0.5rem;">
					<div class="weui_cell">
						<div class="weui_cell_hd"><label class="weui_label">直播页面地址</label></div>
						<div class="weui_cell_bd weui_cell_primary">
						<textarea class="weui_textarea" style="background:#f2f2f2;padding:0.2rem" rows="3" ng-model="pagedata.item.url" placeholder="输入直播页面地址"></textarea>
						<div class="help gray" style="font-size:0.6rem">
							<span class="help-block">注意：请复制直播间详情页的链接 例如：
							<span ng-if="pagedata.item.livept=='douyu'">斗鱼直播间：https://www.douyu.com/xxxxx?dyshid=xxxxx&dyshci=xxxxx</span>
							<span ng-if="pagedata.item.livept=='inke'">映客直播间：http://www.inke.cn/liveroom/index.html?uid=xxxxx&id=xxxx</span>
							<span ng-if="pagedata.item.livept=='huajiao'">花椒直播间：https://www.huajiao.com/l/xxxxxx</span>
							<span ng-if="pagedata.item.livept=='yizhibo'">一直播间：https://www.yizhibo.com/xxxxxx</span>
							(以http://或https://开头)</br>[<red>温馨提示</red>]：考虑个大直播流的规则变动频繁，经常会采集不到直播源。建议可以网上搜索一些直播源抓取工具。然后把直播源地址复制到下面的：《视频流》输入框！</span>
						</div>
						</div>
					</div>
				</div>
				<div class="fui-navbar" style="z-index: 999;padding:0.35rem 1rem">
					<a href="javascript:" ng-click="pagedata.getvideo()" class="btn btn-danger btn-banf" style="margin:0;width:100%">确定抓取</a>
				</div>
		</div>
		</div>
</div>
<div ng-include="sys_html('_footer')"></div>
<script>
scope.pagedata.item.livetime=new Date(scope.pagedata.item.livetime);
scope.pagedata.getvideo=function(){
	scope.post_json('/live_add/getvideo/',{'url':scope.pagedata.item.url,'livept':scope.pagedata.item.livept},function(res){
		console.log(res)
		if(res.status==1){
			scope.pagedata.item.infostatus='直播中';
		}else{
			scope.pagedata.item.infostatus='未直播';
		}
		scope.pagedata.item.livept=res.type;
		scope.pagedata.item.typeName=res.typeName;
		if(!res.poster){
			scope.message('获取异常！');
			return false;
		}
		var image=res.poster.split('url=');
		image=image[1];
		if(image){
			image=image.split('&');
			image=decodeURIComponent(image[0]);
		}else{
			image='';
		}
		scope.pagedata.item.image=image?image:scope.pagedata.item.image;
		scope.pagedata.item.video=res.hls_url;
		scope.pagedata.showgetvideourl=false
		scope.$evalAsync();
	})
}
</script>